using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.ConnectionEngine.Adapters;
using Microsoft.ConnectionEngine.Common;

namespace Microsoft.ConnectionEngine.Administration.Core.ServiceProvider
{
    public class SystemAdapter : SystemAdapterBase
    {
        protected override System.Xml.XmlDocument AssembleMessage(Object objMessage, int msgType)
        {
            try
            {
                if (objMessage.GetType() == typeof(string))
                {
                    System.Xml.XmlDocument result = new System.Xml.XmlDocument();
                    result.LoadXml((string)objMessage);
                    return result;
                }
                else
                {
                    return (System.Xml.XmlDocument)objMessage;
                }
            }
            catch (Exception ex)
            {
                throw new SystemAdapterException(
                    SystemAdapterExceptionCause.Hl7PlayloadCreation,
                    "Error Assembling Message Payload",
                    ex);
            }
        }

        protected override void ProcessMessage(System.Xml.XmlDocument xmlMessage, int msgType, out System.Xml.XmlDocument resultXmlMessage, out int resultMsgType)
        {
            resultXmlMessage = xmlMessage;
            resultMsgType = msgType;
        }

    }
}
